const path = require('path');


const Koa = require('koa');
const koaBody = require('koa-body');
const KoaStatic = require('koa-static')
const router= require('../router') 
const errorHandler = require('./errHandler');
const parameter = require('koa-parameter')
const  app = new Koa();


app.use(koaBody({multipart:true,formidable:{
  //在配置选项option里面不推荐使用相对路径
  //在option里面的相对路径，不是相对的当前文件
  uploadDir:path.join(__dirname,'../uploads'),
  keepExtensions:true,

}}));

app.use(KoaStatic(path.join(__dirname,'../uploads'),))

app.use(parameter(app))

app.use(router.routes()).use(router.allowedMethods());

app.on('error',errorHandler)
module.exports = app